<!-- myNotify -->
<template>
<!-- <el-button type="primary" @click='handleTaskAdd()' plain style="float:right">
                新增会议室
                <i class="el-icon-plus"></i>
            </el-button> -->
    <!-- <el-container> -->
        <!-- <el-main style="padding:0 0 0 10px;"> -->
            <!-- 卡片 -->
            <!-- <el-card class="box-card el-card-flex"> -->
                <!-- 表格 -->
                <div style="height:100%">
                    <el-form :inline="true" class="demo-form-inline" @submit.native.prevent>
                        <el-form-item style="float:right">
                            <el-button type="primary" @click='handleTaskAdd()' plain style="float:right">
                                新增会议室
                                <i class="el-icon-plus"></i>
                            </el-button>
                        </el-form-item>
                    </el-form>
                    <div style="height:90%">
                        <el-table border height="100%" :data="tableData" stripe ref="tableData">
                            <el-table-column prop="roomName" min-width="100px" label="会议室名称" align="left" sortable
                                show-overflow-tooltip></el-table-column>
                            <el-table-column prop="rootCatName" min-width="100px" label="类型" align="left" sortable
                            show-overflow-tooltip></el-table-column>
                            <el-table-column prop="mebmers" min-width="100px" label="容纳（人数）" align="right" sortable
                                show-overflow-tooltip></el-table-column>
                            <el-table-column prop="orgName" min-width="100px" label="所属组织" align="left" sortable
                            show-overflow-tooltip></el-table-column>
							<el-table-column prop="enabled" width="110px" label="启用" align="center" sortable
							show-overflow-tooltip>
							    <template slot-scope="scope">
							        <el-switch v-model="scope.row.enabled" active-value="Y" inactive-value="N" @change="appStatusclick(scope.$index, scope.row)"></el-switch>
							    </template>
							</el-table-column>
                            <el-table-column prop="control" align="center" label="操作" width='110'>
                                <template slot-scope="scope">
                                <el-button class="td-btn-icon" type="text" title="编辑" @click='handleTaskEdit(scope.$index, scope.row)' icon="el-icon-edit"></el-button>
                                    <el-button class="td-btn-icon" type="text" title="删除" @click.native.prevent="deleteRow(scope.$index, scope.row)" icon="el-icon-delete"></el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                    <!-- <el-pagination style="background: #fff; height: 32px; padding-top: 11px;left: 7px;" class="pagination" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    background :current-page="currentPage" :page-sizes="[20, 25, 30, 35]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
                    :total="total"></el-pagination> -->
            </div>
                <!-- 
            </el-card>
        </el-main>
    </el-container> -->
        
</template>
    <script>
        import {
            Tree,
            Dialog,
            Table,
            TableColumn,
            Pagination,
            MessageBox,
            Message,
            Tag,
            Upload,
            Drawer
        } from 'element-ui';
        import {
            taskList, //列表数据
        } from '@/api/missionCenter/missionCenter.js'
        import {
            allList, //全部会议室列表
            delRoom, //删除会议室
            putRoom, //修改会议室
        } from '@/api/conference/conferenceManage.js'
        export default {
            name: 'conferenceAll',
            components: {
            'el-tree': Tree, //树形菜单
            'el-dialog': Dialog, //对话框
            'el-table': Table, //表格
            'el-table-column': TableColumn, //表格列
            'el-pagination': Pagination, //分页
            'el-tag': Tag, //标签
            'el-upload': Upload,
            'el-drawer': Drawer,
            },
            data() {
                return {
                    pageSize: 20,
                    total: 0,
                    currentPage: 1,
                    tableData:[],
                };
            },
            
            created() {
                this.getTabTree()
                window.onresize = () => {
                    this.$refs.tableData.doLayout()
                }
            },
            methods: {
                getTabTree(){
                  allList({

                  }).then(res => {
                    if(res.data.code == 10000){
                      this.tableData = res.data.data.records
                      this.tableData.forEach((v)=>{
                          
                      })
                      setTimeout(()=>{
                          this.$refs.tableData.doLayout()
                      },0)
                    }
                  }).catch(res => {
                    resolve([])
                  })
                },
                
                //编辑
                handleTaskEdit(index,row){
                    this.dialogAppVisible = true;
                    this.dialogAppTitle = '修改分类'
                    this.handleDetails(index,row.roomId)
                },
                // 点击tabel里的应用状态触发编辑接口事件
                appStatusclick(index, row) {
                   
                    putRoom({
                        "roomName": row.roomName,
                        "roomCatId": row.roomCatId,
                        "mebmers": row.mebmers,
                        "orgRangeList": row.orgRangeList,
                        "positionId": row.positionId,
                        "positionName":row.positionName,
                        "waiterList": row.waiterList,
                        "enabled": row.enabled,
                        "price": row.price,
                        "deviceList": row.deviceList,
                        "roomDesc": row.roomDesc,
                        "roomId": row.roomId,
                        "roomCode":row.roomCode
                    }).then(res => {
                        if (res.data.code === 10000) {
                            Message.success('操作成功')
                            this.getTabTree()
                        }
                    })
                },
                //删除
                deleteRow(index,row){
                    console.log()
                    var id = row.roomId
                    MessageBox.confirm('您是否确定删除选中内容', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    })
                    .then(() => {
                        delRoom(id).then(res => {
                        if(res.data.code == 10000){
                            Message({
                            type: 'success',
                            message: '删除成功'
                            });
                             this.getTabTree()
                        }else{
                            // Message({
                            //     type: 'error',
                            //     message: res.data.msg
                            // });
                        }
                        
                        }).catch(res => {
                        
                        })
                    })
                },
               //新增
                handleTaskAdd(){
                    this.handleDetails(1,'object')
                },
        
                /*跳转到新增功能路由组件*/
                handleDetails(index,row) {
                    //this.multiRouters是全局提供的自动添加多级路由的方法
                    this.$router.addRoutes(this.multiRouters([{
                        path: 'createConference',
                        name: 'createConference', //自定义name名称
                        component: () => import('@/views/conference/conferenceManage/createConference'),
                        meta: {
                            title: '会议室'
                        }
                    }]));
                    this.$router.push(this.routerMatch({
                        name: "createConference", //顶部导航+侧边导航
                        params: {
                            row: row
                        }
                    }))
                },
                
                handleSizeChange(val) { //每页条数
                  this.pageSize = val;
                  this.getTabTree(this.formInline)
                },
                handleCurrentChange(val) { //当前页数
                  this.currentPage = val;
                  this.getTabTree(this.formInline)
                },
            }
        };
    </script>
          
<style lang="scss" scoped>
    .el-card__body {
        position: relative;
    }
    
    .pagination.el-pagination {
        position: absolute;
        bottom: 5px;
        left: 15px;
    }
    
    .el-form-tag {
        margin-bottom: 8px !important;
    }
    
    .el-form-tag .el-tag {
        margin-bottom: 10px;
        margin-left: 0 !important;
        margin-right: 10px !important;
    }
    .el-input:not(.el-input--suffix) .el-input__inner[readonly]{
        background: none!important;
    }
    .el-tabs--border-card>.el-tabs__content{
        padding: 0;
    }
</style>
          
          